const express = require("express");

const router = express.Router();

const expressJoi = require("@escook/express-joi");

const {
  login,
  register,
  getUsers,
  getUser,
  updateUser,
  delUser,
  disUser,
} = require("../control/user");
const { userSchema, userId } = require("../schema/user");

//登录
router.post("/login", expressJoi(userSchema), login);

//注册
router.post("/register", expressJoi(userSchema), register);

//获取用户列表
router.get("/users", getUsers);

//根据id获取用户信息
router.get("/users/:id", expressJoi(userId), getUser);

//更新用户信息
router.put("/users/:id", expressJoi(userId), updateUser);

//删除用户
router.delete("/users/:id", expressJoi(userId), delUser);

module.exports = router;
